<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/28 0028
 * Time: 12:52
 */

namespace app\common;


use think\Controller;
use think\Response;

class BaseController extends Controller
{
    protected $beforeActionList=[
        "checkHost"
    ];
    private $allowHost=[
        "39.106.207.193",
        "localhost",
        "127.0.0.1"
    ];

    /**
     * @Notes:过滤Host
     * @Interface checkHost
     * @author: zcx
     * @Time: 2019/5/28 0028   15:30
     */
    public function checkHost(){
        $host=request()->header("Host");
        if(stripos($host,":")){
            $host=substr($host,0,stripos($host,":"));
        }
        if(!in_array($host,$this->allowHost)){
            json([
                "msg"   =>$host."不在允许列表中,请联系管理员",
                "allowHost" =>$this->allowHost
            ])->send();
            die;
        }
    }
}